﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Chinaer.UI.MVC.Controllers
{
    public class EmployeeController : Controller
    {
        //
        // GET: /Employee/

        public ActionResult Index()
        {
            return View();
        }
        /// <summary>
        /// 根据店铺获取员工信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ContentResult GetEmployeesByDianPuID(string id)
        {
            Chinaer.WCF.Services.ChinaerService chinaerService = new WCF.Services.ChinaerService();
            var result = chinaerService.GetEmployeesByDianPuID(id, "");
            return new ContentResult()
            {
                Content = Helper.JsonHelper.GetJson(result, result.Count)
            };
        }
        [HttpPost]
        public string SaveEmployee(DTO.EmployeeDTO employeeDTO)
        {
            Chinaer.WCF.Services.ChinaerService chinaerService = new WCF.Services.ChinaerService();
            var result = chinaerService.AddEmployee(employeeDTO);
            return Helper.JsonHelper.CreateJson(result);
        }
        [HttpPost]
        public string UpdateEmployee(DTO.EmployeeDTO employeeDTO)
        {
            Chinaer.WCF.Services.ChinaerService chinaerService = new WCF.Services.ChinaerService();
            var result = chinaerService.UpdateEmployee(employeeDTO);
            return Helper.JsonHelper.CreateJson(result);
        }
        [HttpPost]
        public string DeleteEmployee(string id)
        {
            Chinaer.WCF.Services.ChinaerService chinaerService = new WCF.Services.ChinaerService();
            var result = chinaerService.DeleteEmployeeByID(id, "");
            return Helper.JsonHelper.CreateJson(result);
        }
    }
}
